package com.schoolcloud.share.controller;

import com.schoolcloud.common.model.R;
import com.schoolcloud.share.dto.ShareVideoSaveDTO;
import com.schoolcloud.share.entity.Videos;
import com.schoolcloud.share.query.VideoQuery;
import com.schoolcloud.share.service.VideosService;
import com.schoolcloud.share.vo.ShareVideoInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/share/video")
@RequiredArgsConstructor
public class ShareVideoController {
    private final VideosService videosService;

    @PostMapping
    public R<?> createVideo(@RequestBody ShareVideoSaveDTO videos) {
        Videos video = videosService.createVideo(videos);
        return R.ok("创建成功", video);
    }
    @GetMapping("/page")
    public R<?> getVideoPage(VideoQuery query) {
        return R.ok(videosService.getVideoPage(query));
    }
    @GetMapping("/info/{id}")
    public R<?> getVideoInfo(@PathVariable Integer id) {
        ShareVideoInfo byId = videosService.getVideoInfo(id);
        return R.ok(byId);
    }
    @GetMapping("/list/notRelated")
    public R<?> getNotRelationVideoList(VideoQuery query) {
        return R.ok(videosService.getNotRelationVideoList(query));
    }
}
